package com.show.mytest;

public class ConsumeThread implements Runnable {
    private Resource r;

    public ConsumeThread(Resource r) {
        this.r = r;
    }

    @Override
    public void run() {
        while (true){
            synchronized (r){
                if (r == null){
                    try {
                        r.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(r);
                try {
                    r.notify();
                    r.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
